package org.bit.createThread;

/**
 * 继承 Thread,重写 run,使用匿名内部类
 */
public class Demo04_Create {
    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("承 Thread,重写 run,使用匿名内部类...");
                }
            }
        };
        // 启动线程
        thread.start();
    }


/*    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("通过Thread匿名内部类的方式创建线程...");
                }
            }
        };
        //启动线程
        thread.start();
    }*/
}
